/*
 * Copyright (c) 2013 WDCY Information Technology Co. Ltd
 * www.wdcy.cc
 * All rights reserved.
 *
 * This software is the confidential and proprietary information of
 * WDCY Information Technology Co. Ltd ("Confidential Information").
 * You shall not disclose such Confidential Information and shall use
 * it only in accordance with the terms of the license agreement you
 * entered into with WDCY Information Technology Co. Ltd.
 */
package com.monkey.core.web;

import org.springframework.util.Assert;

import javax.servlet.ServletRequest;

/**
 * 把request对象放入到ThreadLocal
 *
 * @author Wu Tianqiang
 */
public class ServletRequestContextHolder {

    private static final ThreadLocal<ServletRequest> requestContextHolder = new ThreadLocal<>();

    private ServletRequestContextHolder() {
    }

    public static void clearRequest() {
        requestContextHolder.remove();
    }

    public static ServletRequest getRequest() {
        return requestContextHolder.get();
    }

    public static void setRequest(ServletRequest request) {
        Assert.notNull(request);
        requestContextHolder.set(request);
    }

}